package cn.zhangxin.pethome.base.service.impl;

import cn.zhangxin.pethome.base.mapper.BaseMapper;
import cn.zhangxin.pethome.base.query.BaseQuery;
import cn.zhangxin.pethome.base.service.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class BaseServiceImpl<E> implements IBaseService<E> {
    @Autowired
    private BaseMapper<E> baseMapper;
    @Override
    public E findOne(Long id) {
        return baseMapper.findOne(id);
    }

    @Override
    public List<E> findAll() {
        return baseMapper.findAll();
    }

    @Override
    public List<E> findByQuery(BaseQuery baseQuery) {
        return baseMapper.findByQuery(baseQuery);
    }

    @Override
    public Long findByQueryCount(BaseQuery baseQuery) {
        return baseMapper.findByQueryCount(baseQuery);
    }
    //批量删除
    @Transactional
    @Override
    public void batchDel(List<Long> ids) {
        baseMapper.batchDel(ids);
    }

    @Transactional
    @Override
    public void add(E e) {
        baseMapper.add(e);
    }

    @Transactional
    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }
    @Transactional
    @Override
    public void update(E e) {
        baseMapper.update(e);
    }
}
